<template>
  <view class="payment-container">
    <scroll-view :scroll-y="true" class="scroll-view">
      <!-- 地址信息 -->
      <view class="card address-card">
        <view class="left">
          <uv-icon name="map-fill" size="20" color="#ffde58"></uv-icon>
          <view class="info">
            <text class="location">长沙市开福区人民政府</text>
            <text class="user-info">余 18570729821</text>
          </view>
        </view>
        <view class="right">
          <uv-button
            type="primary"
            size="mini"
            shape="circle"
            text="修改地址"
            :customStyle="{ backgroundColor: '#ffde58', color: '#333', border: 'none' }"
          ></uv-button>
        </view>
      </view>

      <!-- 服务时间 -->
      <view class="card time-card">
        <view class="left">
          <uv-icon name="calendar" size="20"></uv-icon>
          <text class="label">服务时间</text>
        </view>
        <view class="right">
          <text class="time-picker">请选择预约时间</text>
          <uv-icon name="arrow-right" color="#999"></uv-icon>
        </view>
      </view>

      <!-- 订单详情 -->
      <view class="card order-details-card">
        <view class="service-header">
          <uv-icon name="tags-fill" size="20"></uv-icon>
          <text class="title">寻味美食</text>
        </view>
        <view class="service-body">
          <image src="/static/images/service1.jpg" class="service-image"></image>
          <view class="service-info">
            <text class="provider">余 18570729821</text>
            <view class="tags">
              <text class="tag">不满意包退换</text>
              <text class="tag">纯绿陪玩</text>
            </view>
          </view>
          <view class="price-section">
            <text class="price">¥210.00</text>
            <text class="unit">x1</text>
            <uv-number-box v-model="quantity"></uv-number-box>
          </view>
        </view>
        <view class="fee-row">
          <text>车费(全程共4.3公里):</text>
          <text>¥35.98</text>
        </view>
        <view class="fee-row">
          <text>卡券优惠</text>
          <view class="right">
            <text class="coupon">0张可用</text>
            <uv-icon name="arrow-right" color="#999"></uv-icon>
          </view>
        </view>
      </view>

      <!-- 支付方式 -->
      <view class="card payment-method-card">
        <view class="method-row">
          <view class="left">
            <uv-icon name="weixin-fill" size="24" color="#04be02"></uv-icon>
            <text>微信支付</text>
          </view>
          <radio :checked="paymentMethod === 'wechat'" @click="paymentMethod = 'wechat'" color="#ffde58" />
        </view>
        <view class="method-row">
          <view class="left">
            <uv-icon name="rmb-circle-fill" size="24" color="#ff9900"></uv-icon>
            <text>余额支付</text>
            <text class="balance">余额¥0</text>
          </view>
          <radio :checked="paymentMethod === 'balance'" @click="paymentMethod = 'balance'" color="#ffde58" />
        </view>
      </view>

      <!-- 平台协议 -->
      <view class="agreement-section">
        <radio :checked="agreed" @click="agreed = !agreed" color="#ffde58"></radio>
        <text>我已阅读并同意《平台交易规则》</text>
      </view>

    </scroll-view>

    <!-- 底部操作栏 -->
    <view class="bottom-bar">
      <view class="total-price">
        <text>合计：</text>
        <text class="amount">¥665.98</text>
      </view>
      <uv-button
        type="primary"
        shape="circle"
        text="立即支付"
        :customStyle="{ backgroundColor: '#ffde58', color: '#333', border: 'none', width: '180px' }"
      ></uv-button>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const quantity = ref(3);
const paymentMethod = ref('wechat');
const agreed = ref(false);
</script>

<style lang="scss" scoped>
.payment-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f7f8fa;
}

.scroll-view {
  flex: 1;
  padding-bottom: 90px; /* 为底部操作栏留出空间 */
}

.card {
  background-color: #fff;
  border-radius: 12px;
  margin: 12px;
  padding: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.address-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left {
    display: flex;
    align-items: center;
    .info {
      margin-left: 10px;
      display: flex;
      flex-direction: column;
      .location {
        font-size: 16px;
        font-weight: bold;
      }
      .user-info {
        font-size: 13px;
        color: #666;
        margin-top: 4px;
      }
    }
  }
}

.time-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left {
    display: flex;
    align-items: center;
    .label {
      margin-left: 10px;
      font-size: 15px;
    }
  }
  .right {
    display: flex;
    align-items: center;
    .time-picker {
      color: #999;
      font-size: 14px;
      margin-right: 5px;
    }
  }
}

.order-details-card {
  .service-header {
    display: flex;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #f5f5f5;
    .title {
      font-size: 16px;
      font-weight: bold;
      margin-left: 8px;
    }
  }
  .service-body {
    display: flex;
    padding: 15px 0;
    .service-image {
      width: 60px;
      height: 60px;
      border-radius: 8px;
      margin-right: 12px;
    }
    .service-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      .provider {
        font-size: 14px;
      }
      .tags {
        display: flex;
        margin-top: 8px;
        .tag {
          font-size: 11px;
          background-color: #fff8e1;
          color: #f9a825;
          padding: 2px 6px;
          border-radius: 4px;
          margin-right: 6px;
        }
      }
    }
    .price-section {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      .price {
        font-size: 16px;
        font-weight: bold;
      }
      .unit {
        font-size: 12px;
        color: #999;
      }
      .uv-number-box {
        margin-top: 8px;
      }
    }
  }
  .fee-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    padding: 10px 0;
    color: #333;
    .right {
      display: flex;
      align-items: center;
      .coupon {
        color: #ff5050;
        margin-right: 5px;
      }
    }
  }
}

.payment-method-card {
  .method-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    &:not(:last-child) {
      border-bottom: 1px solid #f5f5f5;
    }
    .left {
      display: flex;
      align-items: center;
      font-size: 15px;
      .uv-icon {
        margin-right: 10px;
      }
      .balance {
        font-size: 12px;
        color: #999;
        margin-left: 8px;
      }
    }
  }
}

.agreement-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 15px;
  font-size: 13px;
  color: #666;
  radio {
    transform: scale(0.8);
  }
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  padding: 10px 20px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
  padding-bottom: calc(10px + constant(safe-area-inset-bottom));
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  .total-price {
    font-size: 14px;
    .amount {
      font-size: 20px;
      font-weight: bold;
      color: #ff5050;
    }
  }
}
</style>
